import request from "@/utils/request";
// 菜单基础URL
const MONITOR_BASE_URL = "/wz/monitor";

class MonitorAPI {
  /**
   * @returns 服务监控
   */
  static getServer() {
    return request({
      url: `${MONITOR_BASE_URL}/server`,
      method: "get",
    });
  }

  /**
   * @returns 获取缓存图形数据
   */
  static getCache() {
    return request({
      url: `${MONITOR_BASE_URL}/getCache`,
      method: "get",
    });
  }

  /**
   * @returns 获取缓存名称
   */
  static getCacheNames() {
    return request({
      url: `${MONITOR_BASE_URL}/getCacheNames`,
      method: "get",
    });
  }

  /**
   * @returns 获取缓存对象
   */
  static getKeys(cacheName: string) {
    return request({
      url: `${MONITOR_BASE_URL}/getKeys?cacheName=${cacheName}`,
      method: "get",
    });
  }

  /**
   * @returns 获取缓存对象详细
   */
  static getValue(cacheName: string, key: string) {
    return request({
      url: `${MONITOR_BASE_URL}/getValue?cacheName=${cacheName}&key=${key}`,
      method: "get",
    });
  }
}

export default MonitorAPI;

export interface ServerVO {
  cpu?: CpuVO;
  mem?: MemVO;
  jvm?: JvmVO;
  sys?: SysVO;
  sysFiles?: SysFilesVO[];
}

export interface CpuVO {
  cpuNum?: number;
  total?: number;
  sys?: number;
  used?: number;
  wait?: number;
  free?: number;
}

export interface MemVO {
  total?: number;
  used?: number;
  free?: number;
  usage?: number;
}

export interface JvmVO {
  total?: number;
  max?: number;
  free?: number;
  version?: string;
  home?: string;
  inputArgs?: string;
  runTime?: string;
  name?: string;
  startTime?: string;
  usage?: number;
  used?: number;
}

export interface SysVO {
  computerName?: string;
  computerIp?: string;
  userDir?: string;
  osName?: string;
  osArch?: string;
}

export interface SysFilesVO {
  dirName?: string;
  sysTypeName?: string;
  typeName?: string;
  total?: string;
  free?: string;
  used?: string;
  usage?: number;
}

export interface SysCacheVO {
  cacheName?: string;
  remark?: string;
}
